import WithRouter from "../router/withRouter";
import { Component } from "react";
import Child from "../components/Child";
class Info extends Component{
    state={
        name:"",
        price:""
    }
    render(){
        return (
            <div>
                <h1>详情---{this.state.name}----{this.state.price}</h1>
                <Child name={this.state.name}/>
               {/* < ComponentHook  name={this.state.name}></ComponentHook> */}
            </div>
        )
    }
    
    componentDidMount(){
        console.log(this)
        let {searchParams} = this.props.router;
        let [search,setSearch] = searchParams;
        let name = search.get("name");
        let price= search.get("price");
        console.log(name,price)
        this.setState({
            name,
            price
        })
        /* 
        this.props.router.params 获取动态路由参数
        this.props.router.loaction 获取state传递的参数
        this.props.router.searchParams 获取 search传递参数
        this.porps.router.navaigate 跳转路由
        
        */
    }
}
export default WithRouter(Info)